<?php
//require section
require_once dirname(dirname(__FILE__)) . '/shared/config/config.php';
require_once DOCUMENT_ROOT . DIR_INCLUDE . '/check_user_cinema_login.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_security.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_booking.php';
$title = 'Admin Page';

$booking_code = filter_input(INPUT_POST, "txt_booking_code");

$error_show = "";
$success_info = "";

if (!empty($booking_code)) {
    if (api_booking::search_existing_code($booking_code)) {
        $success_info = "Booking Code Existing!";
    } else {
        $error_show = "Booking Code Not Found.";
    }
}

?>

<!DOCTYPE html>
<html>
    <head>
        <?php
        require_once DOCUMENT_ROOT . DIR_ADMIN_INCLUDE . 'head.php';
        ?>
    </head>
    <body>
        <div class="ui page grid">
            <div class="column ts-wrapper">
                <?php
                require_once DOCUMENT_ROOT . DIR_ADMIN_INCLUDE . 'header.php';
                ?>
                <div class="ts-inner-wrapper" style="min-height: 700px">
                    <h1>Welcome to Administrator Panel for Cinema</h1>
                    
                    
                                <?php if (!empty($error_show)) { ?>
                                    <div class="ui error message">
                                        <i class="close icon"></i>
                                        <div class="header">
                                            <?php echo $error_show; ?>
                                        </div>
                                    </div>
                                <?php } else if (!empty($success_info)) {
                                    ?>
                                <div class="ui success message">
                                        <div class="header">
                                            <?php echo $success_info; ?>
                                        </div>
                                </div>
                                    <?php
                                } else if (!empty($info)) {
                                    echo $info;
                                }
                                ?>
                    
                    
                    
                    <div class="ui form segment form-background">
                        <form action="?" method="POST" id="form_search_booking_code" name="form_search_booking_code">
                    <div class="field">
                        <label for="txt_booking_code">Booking Code</label>
                        <input id="txt_booking_code" name="txt_booking_code" placeholder="Put your code here" type="text" />
                    </div>
                    
                    <div class="ui buttons">
                        <div id="action-button" class="ui orange button" onclick="search_booking_code();"><i class="search icon"></i> Search</div>
                    </div>
                    </form>
                    </div>
                </div>
                <?php
                require_once DOCUMENT_ROOT . DIR_ADMIN_INCLUDE . 'footer.php';
                ?>
            </div>
        </div>
    </body>
</html>